/*
 * @Author: LIFM0623 1944099171@qq.com
 * @Date: 2024-01-11 22:39:07
 * @LastEditors: EyeSklear 1814580085@qq.com
 * @LastEditTime: 2024-04-15 15:01:52
 * @FilePath: \Scene_Back\src\map-ease\map-ease.controller.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import {
  Body,
  Controller,
  Delete,
  Get,
  Param,
  Patch,
  Post,
  Req,
} from '@nestjs/common';
import { MapEaseService } from './map-ease.service';
import { createMapEaseDto } from './dto/create-mapEase.dto';
import { updateMapEaseDto } from './dto/update-mapEase.dto';
import { Request } from 'express';

@Controller('map-ease')
export class MapEaseController {
  constructor(private readonly mapEaseService: MapEaseService) {}

  @Post('createMapEaseItem')
  createMapEaseItem(
    @Body() creatMapEaseDto: createMapEaseDto,
    @Req() request: Request,
  ) {
    const user = request.user;
    creatMapEaseDto.creator = (user as any).email;
    return this.mapEaseService.createMapEaseItem(creatMapEaseDto);
  }

  @Get('getAllMapEaseItem')
  getAllMapEase() {
    return this.mapEaseService.findAll();
  }

  @Get('getMapEaseItemByUser/:uploader')
  getMapEaseItemByUser(@Param('uploader') uploader: string) {
    return this.mapEaseService.findUser(uploader);
  }

  @Get('getMapEaseItemById/:id')
  getMapEaseItemById(@Param('id') id: string) {
    return this.mapEaseService.findOne(id);
  }

  @Patch('updateMapEaseItemById/:id')
  updateMapEaseItemById(
    @Body() updateMapEaseItem: updateMapEaseDto,
    @Param('id') id: string,
  ) {
    return this.mapEaseService.update(id, updateMapEaseItem);
  }

  @Delete('deleteMapEaseItemById/:id')
  deleteMapEaseItemById(@Param('id') id: string) {
    return this.mapEaseService.remove(id);
  }
}
